/* --------------------------------------
SUMMARY: 	- Estimate Counterfactuals
			- Exporting results in Table
AUTHOR: Thimo De Schouwer (KU LEUVEN)
STATA VERSION: MP 18.5
--------------------------------------- */

clear all
drop _all

* Import dataset with preferences attached
cd "${dir}\DataCode\Data\Constructed\LISS"
use Clean_LISS_Preferences.dta , clear

rename child children

** Observed Wages
gen ln_hwage_w = log(hourwage) if woman==1
gen ln_hwage_m = log(hourwage) if woman==0

mean ln_hourwage, over(woman children)

* Total Compensation
gen ln_tc = ln(hourwage + hourwage * wtp_tc * high_telecommute ///
	+ hourwage * wtp_fl * high_flex ///
	+ hourwage * wtp_mw * high_meaning)
	
mean ln_tc, over(woman children)

* Meaning and Counterfactual Flexibility Distribution
gen high_flex2 = high_flex + 1 if high_meaning == 1 & high_flex == 0

gen lc_tc_cf1 = ln(hourwage + hourwage * wtp_tc * high_telecommute ///
	+ hourwage * wtp_fl * high_flex2 ///
	+ hourwage * wtp_mw * high_meaning)
	replace lc_tc_cf1 = ln_tc if lc_tc_cf1 == .

* Counterfactual Meaning and Flexibility Distribution
gen high_meaning2 = high_meaning + 1 if (high_telecommute == 1 | high_flex == 1) & high_meaning == 0

gen lc_tc_cf2 = ln(hourwage + hourwage * wtp_tc * high_telecommute ///
	+ hourwage * wtp_fl * high_flex ///
	+ hourwage * wtp_mw * high_meaning2)
	replace lc_tc_cf2 = ln_tc if lc_tc_cf2 == .

* Meaning and Counterfactual Flexibility Distribution 2
gen high_telecommute2 = high_telecommute + 1 if high_meaning == 1 & high_telecommute == 0

gen lc_tc_cf3 = ln(hourwage + hourwage * wtp_tc * high_telecommute2 ///
	+ hourwage * wtp_fl * high_flex ///
	+ hourwage * wtp_mw * high_meaning)
	replace lc_tc_cf3 = ln_tc if lc_tc_cf3 == .

* Gender- and Motherhood Gap
eststo observed: reg ln_hourwage i.woman i.children i.woman#i.children, robust
eststo totals: reg ln_tc i.woman i.children i.woman#i.children, robust
eststo counterfactual1: reg lc_tc_cf1 i.woman i.children i.woman#i.children, robust
eststo counterfactual2: reg lc_tc_cf2 i.woman i.children i.woman#i.children, robust
eststo counterfactual3: reg lc_tc_cf3 i.woman i.children i.woman#i.children, robust

label var children "Child"
label var woman "Woman"
label var ln_hourwage "Wages (log)"

** Create Results Table
esttab observed totals counterfactual1 counterfactual3 counterfactual2 using "$dir\GraphsTables\GenderMotherhood.txt", varwidth(30) rename(1.woman "Woman" 1.children "Children" 1.woman#1.children "Women $\times$ Children") modelwidth(30) b(%5.3f) eqlabels(none) collabels(none) mtitles("Observed" "TC" "$\tilde{TC}_{fl'}$" "$\tilde{TC}_{tc'}$" "$\tilde{TC}_{mw'}$") se nofloat nonumbers nonote replace noomitted nobaselevels label nogaps tex
eststo clear

